package com.appwoo.txtws.activity;

import android.app.ProgressDialog;
import android.content.Intent;
import android.content.res.Resources;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AbsListView;
import android.widget.AbsListView.OnScrollListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.RatingBar;
import android.widget.TextView;
import com.appwoo.txtws.adapter.ListViewCreator;
import com.appwoo.txtws.adapter.Page;
import com.appwoo.txtws.adapter.SimpleListAdapter;
import com.appwoo.txtws.app.App;
import com.appwoo.txtws.app.AppActivity;
import com.appwoo.txtws.bean.AutoSoftInfo;
import com.appwoo.txtws.bean.StateBean;
import com.appwoo.txtws.component.Global;
import com.appwoo.txtws.component.RqSP;
import com.appwoo.txtws.service.RecomSoftServer;
import com.appwoo.txtws.wheel.widget.PageListView;
import com.appwoo.txtws.wheel.widget.PageListView.OnRefreshListener;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class AppByTypeActivity extends AppActivity
{
  private SimpleListAdapter<AutoSoftInfo> adapter;
  private AutoSoftInfo asi;
  private StateBean bean = new StateBean();
  private boolean blDataTask = false;
  private Button btnCurrent;
  private ProgressDialog dialog = null;
  private List<AutoSoftInfo> events;
  private Boolean isFoot = Boolean.valueOf(false);
  private int isHot = 0;
  private Boolean isSDCard = Boolean.valueOf(false);
  private PageListView lvList;
  private Page<AutoSoftInfo> page = new Page();
  private String softid = "";
  private String typeID = "";
  private String typeName = "";

  private void initActionBar()
  {
    hideBarHome();
    setBarHomeDrawable(getResources().getDrawable(2130837977));
    if (this.typeName.length() > 0)
      setBarTitle(this.typeName);
    while (true)
    {
      setBarBackOnClickListener(new View.OnClickListener()
      {
        public void onClick(View paramAnonymousView)
        {
          AppByTypeActivity.this.finish();
        }
      });
      setBarHomeOnClickListener(new View.OnClickListener()
      {
        public void onClick(View paramAnonymousView)
        {
        }
      });
      return;
      setBarTitle(getResources().getString(2131427346));
    }
  }

  private void initView()
  {
    this.isSDCard = Boolean.valueOf(Global.isSDCard());
    this.lvList = ((PageListView)findViewById(2131492985));
    this.adapter = new SimpleListAdapter(this.page.getEntries(), new ListViewCreator()
    {
      public View createView(final AutoSoftInfo paramAnonymousAutoSoftInfo, View paramAnonymousView, int paramAnonymousInt)
      {
        if (paramAnonymousView == null)
          paramAnonymousView = App.getLayoutInflater().inflate(2130903122, null);
        ((TextView)paramAnonymousView.findViewById(2131493155)).setText(paramAnonymousAutoSoftInfo.getAsname());
        ((TextView)paramAnonymousView.findViewById(2131493160)).setText(paramAnonymousAutoSoftInfo.getSoftSize());
        ((TextView)paramAnonymousView.findViewById(2131493158)).setText(paramAnonymousAutoSoftInfo.getDesc());
        ImageView localImageView = (ImageView)paramAnonymousView.findViewById(2131493154);
        Button localButton;
        int i;
        int j;
        int k;
        int m;
        if (paramAnonymousAutoSoftInfo.getIsRecd() == 1)
        {
          ((ImageView)paramAnonymousView.findViewById(2131493159)).setVisibility(0);
          AppByTypeActivity.this.loadLogoImage(localImageView, paramAnonymousAutoSoftInfo.getAdicon(), AppByTypeActivity.this.isSDCard);
          RatingBar localRatingBar = (RatingBar)paramAnonymousView.findViewById(2131493157);
          localRatingBar.setVisibility(0);
          localRatingBar.setRating(Float.parseFloat(paramAnonymousAutoSoftInfo.getHotMark()));
          localButton = (Button)paramAnonymousView.findViewById(2131493156);
          i = localButton.getPaddingLeft();
          j = localButton.getPaddingTop();
          k = localButton.getPaddingRight();
          m = localButton.getPaddingBottom();
          if (paramAnonymousAutoSoftInfo.getIsPrecd() != 1)
            break label306;
          localButton.setText(AppByTypeActivity.this.getResources().getString(2131427499));
          localButton.setTextColor(AppByTypeActivity.this.getResources().getColor(2131230724));
          localButton.setBackgroundDrawable(AppByTypeActivity.this.getResources().getDrawable(2130837636));
          localButton.setEnabled(false);
        }
        while (true)
        {
          localButton.setPadding(i, j, k, m);
          localButton.setOnClickListener(new View.OnClickListener()
          {
            public void onClick(View paramAnonymous2View)
            {
              AppByTypeActivity.this.softid = paramAnonymousAutoSoftInfo.getKeyID();
              AppByTypeActivity.this.btnCurrent = ((Button)paramAnonymous2View);
              AppByTypeActivity.this.asi = paramAnonymousAutoSoftInfo;
              new AppByTypeActivity.DataTask(AppByTypeActivity.this).execute(new String[] { "softRecd" });
            }
          });
          paramAnonymousView.setOnClickListener(new View.OnClickListener()
          {
            public void onClick(View paramAnonymous2View)
            {
              MarketTabActivity.staASI = paramAnonymousAutoSoftInfo;
              Bundle localBundle = new Bundle();
              localBundle.putString("softName", paramAnonymousAutoSoftInfo.getAsname());
              localBundle.putString("apkname", paramAnonymousAutoSoftInfo.getAspkg());
              localBundle.putString("author", paramAnonymousAutoSoftInfo.getAuthor());
              localBundle.putString("hotMark", paramAnonymousAutoSoftInfo.getHotMark());
              localBundle.putString("softSize", paramAnonymousAutoSoftInfo.getSoftSize());
              localBundle.putString("softType", paramAnonymousAutoSoftInfo.getTypeName());
              localBundle.putString("updateTime", paramAnonymousAutoSoftInfo.getUpdateTime());
              localBundle.putString("downloadurl", paramAnonymousAutoSoftInfo.getAddownloadurl());
              localBundle.putString("icon", paramAnonymousAutoSoftInfo.getAdicon());
              localBundle.putString("keyid", paramAnonymousAutoSoftInfo.getKeyID());
              localBundle.putString("version", paramAnonymousAutoSoftInfo.getVersion());
              localBundle.putString("fromParent", "1");
              localBundle.putInt("isRecd", paramAnonymousAutoSoftInfo.getIsRecd());
              localBundle.putInt("isPrecd", paramAnonymousAutoSoftInfo.getIsPrecd());
              AppByTypeActivity.this.IntentActivity(AppByTypeActivity.this, SoftInfoActivity.class, localBundle);
            }
          });
          return paramAnonymousView;
          ((ImageView)paramAnonymousView.findViewById(2131493159)).setVisibility(8);
          break;
          label306: localButton.setText(AppByTypeActivity.this.getResources().getString(2131427498));
          localButton.setTextColor(AppByTypeActivity.this.getResources().getColor(2131230728));
          localButton.setBackgroundDrawable(AppByTypeActivity.this.getResources().getDrawable(2130837632));
          localButton.setEnabled(true);
        }
      }
    });
    this.lvList.setAdapter(this.adapter);
    this.lvList.setOnScrollListener(new AbsListView.OnScrollListener()
    {
      public void onScroll(AbsListView paramAnonymousAbsListView, int paramAnonymousInt1, int paramAnonymousInt2, int paramAnonymousInt3)
      {
      }

      public void onScrollStateChanged(AbsListView paramAnonymousAbsListView, int paramAnonymousInt)
      {
        if ((paramAnonymousInt == 0) && (paramAnonymousAbsListView.getLastVisiblePosition() == -1 + paramAnonymousAbsListView.getCount()) && (!AppByTypeActivity.this.lvList.getIsNoMore()) && (AppByTypeActivity.this.blDataTask))
        {
          AppByTypeActivity.this.lvList.prepareForRefreshMore();
          AppByTypeActivity.this.isFoot = Boolean.valueOf(true);
          AppByTypeActivity.this.loadingData(false);
        }
      }
    });
    this.lvList.setOnLoadMoreListener(new PageListView.OnRefreshListener()
    {
      public void onRefresh()
      {
        AppByTypeActivity.this.lvList.prepareForRefreshMore();
        AppByTypeActivity.this.isFoot = Boolean.valueOf(true);
        AppByTypeActivity.this.loadingData(true);
      }
    });
    addOperation(new DataTask().execute(new String[] { "installindex" }));
  }

  private void loadingData(boolean paramBoolean)
  {
    if (paramBoolean)
      this.page.firstPage();
    while (true)
    {
      addOperation(new DataTask().execute(new String[] { "installindex" }));
      return;
      this.page.nextPage();
    }
  }

  protected void backKeyCallBack()
  {
    finish();
  }

  public void onBackPressed()
  {
    finish();
  }

  protected void onCreate(Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    setContentView(2130903143);
    Intent localIntent = getIntent();
    this.typeID = localIntent.getStringExtra("TypeID");
    this.typeName = localIntent.getStringExtra("TypeName");
    if ((this.typeID == null) || (this.typeID.length() == 0))
    {
      this.typeID = "";
      this.typeName = "";
    }
    initActionBar();
    initView();
  }

  protected void onResume()
  {
    super.onResume();
    this.adapter.notifyDataSetChanged();
  }

  class DataTask extends AsyncTask<String, Integer, String>
  {
    String param;

    DataTask()
    {
    }

    protected String doInBackground(String[] paramArrayOfString)
    {
      this.param = paramArrayOfString[0];
      if (this.param.equals("installindex"))
        AppByTypeActivity.this.events = new RecomSoftServer(AppByTypeActivity.this).installSoftWare(AppByTypeActivity.this.isHot, AppByTypeActivity.this.typeID, "", 0, 0, AppByTypeActivity.this.page.getPageNo(), AppByTypeActivity.this.page.getPageSize());
      while (!this.param.equals("softRecd"))
        return null;
      HashMap localHashMap = new HashMap();
      localHashMap.put(AppByTypeActivity.this.softid, Integer.valueOf(1));
      RqSP localRqSP = new RqSP();
      String str1 = localRqSP.getLgDevAccount(AppByTypeActivity.this);
      String str2 = localRqSP.getLgDevId(AppByTypeActivity.this);
      AppByTypeActivity.this.bean = new RecomSoftServer(AppByTypeActivity.this).updateRecd(localHashMap, str1, str2);
      return AppByTypeActivity.this.bean.getDesc();
    }

    protected void onPostExecute(String paramString)
    {
      if (this.param.equals("installindex"))
        if ((AppByTypeActivity.this.events != null) && (AppByTypeActivity.this.events.size() > 0))
        {
          AppByTypeActivity.this.page.addAllEntries(AppByTypeActivity.this.events);
          AppByTypeActivity.this.adapter.notifyDataSetChanged();
          AppByTypeActivity.this.lvList.onLoadMoreComplete();
          if (AppByTypeActivity.this.events.size() < AppByTypeActivity.this.page.getPageSize())
          {
            AppByTypeActivity.this.lvList.hideFotterMoreView();
            AppByTypeActivity.this.lvList.setIsNoMore(true);
          }
          AppByTypeActivity.this.events.clear();
          AppByTypeActivity.this.blDataTask = true;
        }
      while (true)
      {
        if (!AppByTypeActivity.this.isFoot.booleanValue())
        {
          AppByTypeActivity.this.closeProgress();
          AppByTypeActivity.this.isFoot = Boolean.valueOf(false);
        }
        super.onPostExecute(paramString);
        return;
        AppByTypeActivity.this.lvList.hideFotterMoreView();
        AppByTypeActivity.this.lvList.setIsNoMore(true);
        break;
        if (this.param.equals("softRecd"))
          if ("0".equals(AppByTypeActivity.this.bean.getCode()))
          {
            int i = AppByTypeActivity.this.btnCurrent.getPaddingLeft();
            int j = AppByTypeActivity.this.btnCurrent.getPaddingTop();
            int k = AppByTypeActivity.this.btnCurrent.getPaddingRight();
            int m = AppByTypeActivity.this.btnCurrent.getPaddingBottom();
            AppByTypeActivity.this.btnCurrent.setText(AppByTypeActivity.this.getResources().getString(2131427499));
            AppByTypeActivity.this.btnCurrent.setTextColor(AppByTypeActivity.this.getResources().getColor(2131230724));
            AppByTypeActivity.this.btnCurrent.setBackgroundDrawable(AppByTypeActivity.this.getResources().getDrawable(2130837636));
            AppByTypeActivity.this.btnCurrent.setPadding(i, j, k, m);
            AppByTypeActivity.this.asi.setIsPrecd(1);
            AppByTypeActivity.this.adapter.notifyDataSetChanged();
            AppByTypeActivity.this.alertMessage(AppByTypeActivity.this.getResources().getString(2131427527));
          }
          else
          {
            AppByTypeActivity.this.alertMessage(AppByTypeActivity.this.getResources().getString(2131427528));
          }
      }
    }

    protected void onPreExecute()
    {
      AppByTypeActivity.this.blDataTask = false;
      if (!AppByTypeActivity.this.isFoot.booleanValue())
        AppByTypeActivity.this.showProgress("");
      super.onPreExecute();
    }
  }
}

/* Location:           C:\Documents and Settings\Administrator\classes_dex2jar.jar
 * Qualified Name:     com.appwoo.txtws.activity.AppByTypeActivity
 * JD-Core Version:    0.6.2
 */